﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
using Autenticazione.BusinessObject;

namespace Autenticazione
{
    /// <summary>
    /// Summary description for GetTable
    /// </summary>
    public class GetTable : IHttpHandler
    {
        string tableName;

        public void ProcessRequest(HttpContext context)
        {
            tableName = context.Request.QueryString["table"];
            context.Response.ContentType = "text/plain";
            context.Response.Write(SerializeTable());
        }

        private string SerializeTable()
        {
            switch (tableName)
            {
                case "Allenatore":
                    BusinessObject.Coach c = new BusinessObject.Coach();
                    return c.Serialize();
                case "Atleta":
                    BusinessObject.Atleta a = new BusinessObject.Atleta();
                    return a.Serialize();
                case "Club":
                    BusinessObject.Club club = new BusinessObject.Club();
                    return club.Serialize();
                case "Fights":
                    BusinessObject.Fights f = new Fights();
                    return f.Serialize();
                default:
                    break;
            }
            
            return string.Empty;
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}